-
Notifications
You must be signed in to change notification settings - Fork 139
Add x86 Keccak implementation #2619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2619 +/- ##
==========================================
- Coverage 78.74% 78.73% -0.02%
==========================================
Files 646 646
Lines 111300 111304 +4
Branches 15714 15715 +1
==========================================
- Hits 87647 87634 -13
- Misses 22961 22976 +15
- Partials 692 694 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bit Interleave is used for performance optimizations on 32-bit platforms. Bit Interleave adds unnecessary complexity. ### Issues: Some Windows compiler, e.g., old versions of Microsoft Visual C++ (MSVC), do not support some preprocessor directives and expressions, e.g., of the type: ``` // Double-check that bit-interleaving is not used on AArch64 #if BIT_INTERLEAVE != 0 #error Bit-interleaving of Keccak1600 states should be disabled for AArch64 #endif ``` in https://github.com/aws/aws-lc/blob/d781046a99638d1466ec912cf0191d0564de2084/crypto/fipsmodule/sha/keccak1600.c#L422 A solution could be: ``` #if defined(BIT_INTERLEAVE) && BIT_INTERLEAVE #error Bit-interleaving of Keccak1600 states should be disabled for AArch64 #endif ``` However, BIT_INTERLEAVE is intended for only optimizing 32-bit platforms, i.e., it adds unnecessary complexity to the code without providing many benefits. Therefore, removing BIT_INTERLEAVE support is the better solution for clarity and maintainability. ### Description of changes: Remove all support for BIT_INTERLEAVE. ### Call-outs: This change is needed/motivated by the integration of x86 Keccak to aws-lc #2619 which fails when running on x86 Windows platform. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
31b9da6
to
8f49584
Compare
8f49584
to
b7bd113
Compare
b7bd113
to
7f25485
Compare
@@ -349,7 +351,7 @@ void KeccakF1600(uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS]) { | |||
// Neoverse V1 and V2 do support SHA3 instructions, but they are only | |||
// implemented on 1/4 of Neon units, and are thus slower than a scalar | |||
// implementation. | |||
|
|||
#if defined(OPENSSL_AARCH64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe you can && this line and the one below to match l.429.
When you add the brackets as per Dusan's comment, you can maybe do this small change, if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, these are not ending at the same place. There is one additional non-s2n-bignum
assembly implementation for arm, so it should fall back to it if not s2n-bignum
but still aarch64
is detected.
7f25485
to
2f8d6b1
Compare
2f8d6b1
to
39e89e5
Compare
Description of changes:
Add x86 optimized Keccak implementation from s2n-bignum
This PR integrates optimized and formally verified x86 Keccak code from the s2n-bignum library. The code has been imported as-is using our importer script, adding all changes up to commit 717b57ac643327489d2ac7dd4022a64b5dfb2d8f.
Key aspects:
Testing:
ninja && ./crypto/crypto_test
./tool/bssl speed -filter {SHA3-224, ...}
SHA3 Performance Comparison
ASM Implementation vs C Implementation
SHA3 Performance: Details
ASM Implementation
C Implementation
x86 ASM ML-KEM with C vs. ASM SHA3/SHAKE Performance
ASM SHA3/SHAKE vs C SHA3/SHAKE
x86 ASM ML-KEM with ASM SHA3 Implementation
x86 ASM ML-KEM with C SHA3 Implementation
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.